<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

class Entity {

  public function save() {
    return Model::save($this);
  }

  public function delete() {
    return false;
  }

  public function __get($name) {
    $method = 'get' . ucfirst($name);
    if (method_exists($this, $method)) {
      return $this->{$method}();
    } else {
      return @$this->{strtolower(preg_replace('/([a-z0-9])([A-Z])/', '\1_\2', $name))};
    }
  }

  public function __set($name, $value) {
    $method = 'set' . ucfirst($name);
    if (method_exists($this, $method)) {
      $this->{$method}($value);
    } else {
      $this->{strtolower(preg_replace('/([a-z0-9])([A-Z])/', '\1_\2', $name))} = $value;
    }
    return $this;
  }

}
